Skip to content

feat: ensure async timeout works via getAsync, propagate interrupts#3

Merged
k13gomez merged 1 commit intomainfrom
async-fixes
Oct 24, 2025
Merged

feat: ensure async timeout works via getAsync, propagate interrupts#3
k13gomez merged 1 commit intomainfrom
async-fixes

Conversation

@k13gomez
Copy link
Member

@k13gomez k13gomez commented Oct 23, 2025

Details are here, problem described by @bigodel in previous discussion: https://failsafe.dev/execution-cancellation/#limitations

@gemini-code-assist
Copy link

Summary of Changes

Hello @k13gomez, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue in the failsage library where asynchronous operations, particularly those subject to timeouts, were not reliably being canceled. The core problem stemmed from how AsyncExecution was handled, preventing proper interrupt propagation. The changes refactor the asynchronous execution logic to ensure that when a timeout occurs, the underlying futurama future is explicitly canceled and InterruptedException is correctly thrown, preventing resource leaks and ensuring predictable behavior. This update also streamlines the integration with the Failsafe library's asynchronous execution model.

Highlights

  • Async Timeout Fix: Addressed a limitation in AsyncExecution that prevented asynchronous tasks from being canceled properly during timeouts, ensuring reliable termination of long-running operations.
  • Interrupt Propagation: Modified the execute-get-async macro to correctly propagate InterruptedException and trigger async-cancel! on timed-out futurama futures, preventing resource leaks and ensuring predictable behavior.
  • Failsafe API Update: Refactored the asynchronous execution mechanism by switching from FailsafeExecutor.getAsyncExecution with AsyncRunnable to FailsafeExecutor.getAsync with ContextualSupplier, simplifying the internal implementation and aligning with the Failsafe library's recommended approach.
  • Version Bump: Updated the project version from 0.2.0 to 0.3.0 in pom.xml and CHANGELOG.md to reflect these significant changes.
  • Test Enhancements: Added comprehensive new tests to failsage.core-test to thoroughly verify the timeout policy's ability to enforce time limits and propagate interrupts for both synchronous and asynchronous executions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@k13gomez k13gomez requested review from bigodel and hiredman October 23, 2025 14:40
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly refactors the asynchronous execution handling to ensure timeouts and interruptions are properly propagated. The switch from Failsafe's manual AsyncExecution to the CompletableFuture-based .getAsync method is a significant improvement, simplifying the implementation and fixing the underlying issue. The related code and tests have been updated accordingly. I've found one issue in a new test case that needs to be addressed to ensure the fix is properly verified.

@k13gomez k13gomez force-pushed the async-fixes branch 6 times, most recently from 3c5c595 to f16ad94 Compare October 24, 2025 23:37
@k13gomez k13gomez merged commit 94f8960 into main Oct 24, 2025
2 checks passed
@k13gomez k13gomez deleted the async-fixes branch October 24, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants